﻿@model PagedTopicContainer
@using PopForums.Extensions;
@using PopForums.Models

@{
	ViewBag.Title = PopForums.Resources.Search;
	Layout = "~/Areas/PopForums/Views/Shared/PopForumsMaster.mobile.cshtml";
}

@using (Html.BeginForm("Process", "Search"))
{
	@Html.TextBox("Query", null, new { @class = "pf-text" })
	@Html.DropDownList("SearchType", (SelectList)ViewBag.SearchTypes, new { @class = "pf-text" })
	<p><input type="submit" value="@PopForums.Resources.Search" class="pf-button" /></p>
}

@Html.PagerLinksMobile(Url, "Search", "Result", Model.PagerContext)

@helper TopicLink(Topic topic)
	{
	if (this.GetUserFromViewData() == null)
	{
		@Url.Action("Topic", "Forum", new { id = topic.UrlName, page = 1 })
	}
	else
	{
		@Url.Action("GoToNewestPost", "Forum", new { id = topic.TopicID })
	}
}

@if (Model.Topics.Count == 0 && !String.IsNullOrEmpty(ViewBag.Query))
{
	<p>@PopForums.Resources.NoResults</p>
}
else
{
	<ul class="pf-list pf-container">
		<li class="pf-list-item">
			<a href="@Url.Action("Index", PopForums.Controllers.ForumHomeController.Name)" class="pf-indicator-list-link">
				<div class="pf-back"> </div>
				<span class="pf-heading">@PopForums.Resources.ForumHome</span>
			</a>
		</li>
		@foreach (var topic in Model.Topics)
		{
			<li class="pf-list-item@(topic.IsDeleted ? Html.Raw(" deletedItem") : Html.Raw(""))">
				<a href="@TopicLink(topic)" class="pf-indicator-list-link">
					@Html.TopicReadIndicator(topic, Model, "/Content/PopForums/", "pf-indicator")
					<span class="pf-heading">@topic.Title</span>
					<span class="pf-subhead">@PopForums.Resources.Last: @FormatTime(topic.LastPostTime) @PopForums.Resources.By @topic.LastPostName</span>
				</a>
			</li>
		}
	</ul>
}

@Html.PagerLinksMobile(Url, "Search", "Result", Model.PagerContext)